package com.unionftech.common.common.api

import com.unionftech.common.bean.ResponseResult
import com.unionftech.common.common.bean.AppVersionInfo
import com.unionftech.common.common.bean.BannerImageInfo
import com.unionftech.common.common.bean.CountryInfo
import com.unionftech.common.common.bean.UserKYCFileInfo
import com.unionftech.common.common.bean.PhoneRegexInfo
import com.unionftech.common.common.bean.TradePlatform
import com.unionftech.common.common.bean.SystemUserInfo
import com.unionftech.common.common.bean.UserGroupInfo
import com.unionftech.common.recaptcha.RecaptchaInterceptor
import com.unionftech.common.recaptcha.RecaptchaUtil
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Headers
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Query

interface CommonApi {
    /**
     * 获取国家列表
     */
    @GET("fore/user/country")
    suspend fun requestCountryList(): ResponseResult<List<CountryInfo>>

    /**
     * 发送验证码
     */
    @Headers(
        "requestSource:APP",
        "Content-Type:application/json",
        "${RecaptchaInterceptor.KEY_INTERCEPTOR_ACTION}:${RecaptchaUtil.ACTION_SEND_CODE}"
    )

    @POST("system/user/sendCode")
    suspend fun sendCode(
        @Body body: RequestBody, @Header("Authorization") token: String? = null
    ): ResponseResult<Any?>

    @POST("system/user/sendCodeRegister")
    suspend fun sendCodeRegister(
        @Body body: RequestBody
    ): ResponseResult<Any?>

    /**
     * 发送邮箱验证码
     */
    @Headers(
        "requestSource:APP",
        "Content-Type:application/json",
        "${RecaptchaInterceptor.KEY_INTERCEPTOR_ACTION}:${RecaptchaUtil.ACTION_SEND_CODE}"
    )
    @POST("system/user/sendEmailCode")
    suspend fun sendEmailCode(
        @Body body: RequestBody
    ): ResponseResult<Any?>


    /**
     * 通过手机ip获取当前的国家编码信息
     */
    @GET("fore/user/trader/queryCountryByIp")
    suspend fun queryCountryByIp(): ResponseResult<CountryInfo>

    /**
     * 获取国家手机号正则
     */
    @GET("fore/user/country-phone-rule/map")
    suspend fun getCountryPhoneRegex(): ResponseResult<Map<String, String>>

    /**
     * 获取全部国家手机号正则
     */
    @GET("fore/user/country-phone-rule")
    suspend fun getAllCountryPhoneRegex(): ResponseResult<List<PhoneRegexInfo>>

    /**
     * 获取rsa公钥
     */
    @GET("auth/getPublicKey")
    suspend fun getPublicKey(): ResponseResult<String>

    /**
     * 获取外部用户信息
     */
    @GET("trade/user/info")
    suspend fun getOuterUserInfo(@Header("Authorization") token: String): ResponseResult<SystemUserInfo>

    /**
     * 获取用户的补料状态
     */
    @GET("trade/user/trader/infoV148")
    suspend fun getKycInfo(@Header("Authorization") token: String): ResponseResult<UserKYCFileInfo>

    /**
     * 校验邀请码
     */
    @GET("trade/user/trader/checkInvitationCode")
    suspend fun checkInvitationCode(
        @Header("Authorization") token: String, @Query("invitationCode") code: String
    ): ResponseResult<Any?>

    /**
     * 查询虚拟账户平台信息
     */
    @GET("trade/user/querySystemDemoPlatform")
    suspend fun querySystemDemoPlatform(@Header("Authorization") token: String): ResponseResult<List<TradePlatform>>

    /**
     * 根据邀请码获取交易平台信息
     * 平台(1-mt4 2-mt5)
     */
    @GET("trade/user/trader/queryPlatform")
    suspend fun queryPlatform(
        @Header("Authorization") token: String, @Query("invitationCode") code: String
    ): ResponseResult<List<TradePlatform>>


    /**
     * 根据国家,邀請碼,平台,帳號類型,查询支持的币种
     */
    @GET("trade/user/currency/byCountryAndInvite")
    suspend fun queryCurrency(
        @Header("Authorization") token: String,
        @Query("code") code: String,
        @Query("platform") platform: String,
        @Query("tradeType") tradeType: String,
    ): ResponseResult<List<String>>

    /**
     * 根据邀请码查询上级所属组与币种
     */
    @GET("trade/user/trader/queryGroupAndCurrency")
    suspend fun queryGroupAndCurrency(
        @Header("Authorization") token: String,
        @Query("inviteCode") code: String,
    ): ResponseResult<UserGroupInfo>

    /**
     * 根据邀请码查询账户类型
     */
    @GET("trade/user/trader/queryAccountType")
    suspend fun queryAccountType(
        @Header("Authorization") token: String,
        @Query("inviteCode") code: String,
    ): ResponseResult<List<Int>>


    /**
     * 上传图片
     */
    @Multipart
    @POST("publics/upload/pdf")
    suspend fun upload(
        @Part part: MultipartBody.Part
    ): ResponseResult<String>

    /**
     * 获取后台配置轮播图信息
     */
    @GET("system/center/bannerList")
    suspend fun getBannerList(
        @Query("language") languageCode: String,
        @Query("position") position: Int
    ): ResponseResult<List<BannerImageInfo>>


    /**
     * 获取最新的App版本信息
     */
    @GET("system/center/getVersion")
    suspend fun getUpdateInfo(
        @Query("osType") osType: Int,
        @Query("version") versionCode: String,
        @Query("userId") userId: String,
        @Query("deviceModel") device: String,
        @Query("country") country: String
    ): ResponseResult<AppVersionInfo>

}